/* jslint browser: true, devel: true */
/* global event */

const FrameEvents = {
  // 全局变量初始值
  state: {
    // 振铃事件
    eventRinging: 'EventRinging',
    // 通话话建立事件
    eventEstablished: 'EventEstablished',
    // 话后处理事件
    eventAfterCallWork: 'EventAfterCallWork'
  },
  // 获取全局变量
  getters: {
    // 振铃事件
    eventRinging: state => state.eventRinging,
    // 通话话建立事件
    eventEstablished: state => state.eventEstablished,
    // 话后处理事件
    eventAfterCallWork: state => state.eventAfterCallWork
  },
  // 改变全局变量（同步）
  mutations: {
    SET_LANGUAGE: (state, language) => {
      state.language = language
      Cookies.set('lang', language)
    }
  },
  // 改变全局变量（异步）
  actions: {
    setLanguage ({ commit }, language) {
      commit('SET_LANGUAGE', language)
    }
  }
}

export default FrameEvents
